#!python
import boto
from boto.contrib.ymlmessage import YAMLMessage

import sys
from getopt import getopt

# Parse everything
opts, args = getopt(sys.argv[1:], "ht:n:", ['help', 'type=', 'name=', 'title='])

type = "alert"
title = "Alert"
for o, a in opts:
	if o in ("-h", "--help"):
		print "%s: [-h] [-t type] [-n name]" % sys.argv[0]
		exit(0)
	elif o in ("-t", "--type"):
		type = a
	elif o in ("-n", "--name", "--title"):
		title = a

body = sys.stdin.read()

# Connect and send
sqs = boto.connect_sqs()
q = sqs.get_queue(boto.config.get("sqs-growl", "queue"))
q.set_message_class(YAMLMessage)

m = YAMLMessage()
m.data = {}
m.data['title'] = title
m.data['type'] = type
m.data['description'] = body
q.write(m)
